/*
 * @Author: Bo
 * @Date: 2022-03-21 09:19:58
 */
import {
  createRouter,
  createWebHashHistory,
  createWebHistory
} from 'vue-router'

// 1. 定义路由组件， 注意，这里一定要使用 文件的全名（包含文件后缀名）

// 2. 定义路由配置
const routes = [
  {
    path: '/',
    component: () => import('../components/layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('../view/home/index.vue')
      },
      {
        path: '/artical/:id',
        name: 'Artical',
        component: () => import('../view/artical/index.vue')
      },
      {
        path: '/search/:searchText',
        name: 'Search',
        component: () => import('../view/search/index.vue')
      }
    ]
  },
  {
    path: '/',
    component: () => import('../components/layout/NotNavLayout.vue'),
    children: [
      {
        path: '/myself',
        name: 'MySelf',
        component: () => import('../view/mySelf/index.vue')
      }
    ]
  }
]

// 3. 创建路由实例
const router = createRouter({
  // 4. 采用hash 模式
  history: createWebHistory('/vue3/'),
  // 采用 history 模式
  // history: createWebHistory(),
  routes // short for `routes: routes`
})

export default router
